<?php

namespace User\Model\Entity;

class ModuleSettings implements ModuleSettingsInterface {
	/**
	 * @var int
	 */
	protected $id;
	
	/**
	 * @var string
	 */
	protected $loginRoute;
	
	/**
	 * @var string
	 */
	protected $redirectRouteLogin;

	/**
	 * @var string
	 */
	protected $redirectRouteLogout;

	/**
	 * @var bool
	 */
	protected $loginAfterRegistration;

	/**
	 * @var bool
	 */
	protected $registrationEnable;

	/**
	 * @var bool
	 */
	protected $registrationUseFormCaptcha;

	/**
     * @var array
     */
    protected $formCaptchaOptions = array(
    	'font' => 'public/font/arial.ttf',
    	'imgAlt' => 'Captcha',
    	'imgDir' => 'public/img/captcha/',
    	'imgUrl' => '/img/captcha/',
    	'wordLen' => 5,
    	'dotNoiseLevel' => 10,
    	'lineNoiseLevel' => 2,
    	'expiration' => 300,
    );
    
	/**
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function __construct($data = null) {
		if(is_array($data)) {
			$this->exchangeArray($data);
		}
	}

	/**
	 * The new array to exchange with the current object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function exchangeArray(array $data) {
		$this->id							= (isset($data['user_module_settings_id']))			? $data['user_module_settings_id']			: null;
		$this->loginRoute					= (isset($data['login_route']))						? $data['login_route']						: null;
		$this->redirectRouteLogin			= (isset($data['redirect_route_login']))			? $data['redirect_route_login']				: null;
		$this->redirectRouteLogout			= (isset($data['redirect_route_logout']))			? $data['redirect_route_logout']			: null;
		$this->loginAfterRegistration		= (isset($data['login_after_registration']))		? $data['login_after_registration']			: null;
		$this->registrationEnable			= (isset($data['registration_enable']))				? $data['registration_enable']				: null;
		$this->registrationUseFormCaptcha	= (isset($data['registration_use_form_captcha']))	? $data['registration_use_form_captcha']	: null;
	}

	/**
	 * A copy of the array, or array of public properties if ArrayIterator refers to an object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @return array
	 */
	public function getArrayCopy() {
		return get_object_vars($this);
	}

	/**
	 * @return int
	 */
	public function getId() {
		return $this->id;
	}

	/**
	 * @param int $id
	 * @return ModuleSettings
	 */
	public function setId($id) {
		$this->id = $id;
		return $this;
	}
	
	/**
	 * @return string
	 */
	public function getLoginRoute() {
		return $this->loginRoute;
	}

	/**
	 * @param string $loginRoute
	 * @return ModuleSettings
	 */
	public function setLoginRoute($loginRoute) {
		$this->loginRoute = $loginRoute;
		return $this;
	}
	
	/**
	 * @return string
	 */
	public function getRedirectRouteLogin() {
		return $this->redirectRouteLogin;
	}

	/**
	 * @param string $redirectRouteLogin
	 * @return ModuleSettings
	 */
	public function setRedirectRouteLogin($redirectRouteLogin) {
		$this->redirectRouteLogin = $redirectRouteLogin;
		return $this;
	}
	
	/**
	 * @return string
	 */
	public function getRedirectRouteLogout() {
		return $this->redirectRouteLogout;
	}

	/**
	 * @param string $redirectRouteLogout
	 * @return ModuleSettings
	 */
	public function setRedirectRouteLogout($redirectRouteLogout) {
		$this->redirectRouteLogout = $redirectRouteLogout;
		return $this;
	}
	
	/**
	 * @return bool
	 */
	public function getLoginAfterRegistration() {
		return $this->loginAfterRegistration;
	}

	/**
	 * @param string $loginAfterRegistration
	 * @return ModuleSettings
	 */
	public function setLoginAfterRegistration($loginAfterRegistration) {
		$this->loginAfterRegistration = $loginAfterRegistration;
		return $this;
	}
	
	/**
	 * @return bool
	 */
	public function getRegistrationEnable() {
		return $this->registrationEnable;
	}

	/**
	 * @param string $registrationEnable
	 * @return ModuleSettings
	 */
	public function setRegistrationEnable($registrationEnable) {
		$this->registrationEnable = $registrationEnable;
		return $this;
	}
	
	/**
	 * @return bool
	 */
	public function getRegistrationUseFormCaptcha() {
		return $this->registrationUseFormCaptcha;
	}

	/**
	 * @param string $registrationUseFormCaptcha
	 * @return ModuleSettings
	 */
	public function setRegistrationUseFormCaptcha($registrationUseFormCaptcha) {
		$this->registrationUseFormCaptcha = $registrationUseFormCaptcha;
		return $this;
	}
	
	/**
	 * @return array
	 */
	public function getFormCaptchaOptions() {
		return $this->formCaptchaOptions;
	}
	
	/**
	 * @param array $formCaptchaOptions
	 * @return ModuleSettings
	 */
	public function setFormCaptchaOptions($formCaptchaOptions) {
		$this->formCaptchaOptions = $formCaptchaOptions;
		return $this;
	}
}